unit TestNullableStrings;

interface

uses
  TestFramework, Variants, NullableStrings, SysUtils;

type
  // Test methods for NullableString

  TestNullableString = class(TTestCase)
  strict private
  private
    procedure ReadUnint;
    procedure ReadNull;
  published
    procedure TestAddition;

    procedure TestUninit;
    procedure TestReadNull;
  end;

implementation

uses NullableTypes;

procedure TestNullableString.TestAddition;
var
  n1, n2: NullableString;
begin
  n1 := 'n1';
  n2 := n1 + ' & n2';
  CheckEquals('n1 & n2', n2);
end;

procedure TestNullableString.ReadNull;
var
  n: NullableString;
  s: string;
begin
  n.IsNull := True;
  s := n; // Should generate exception
  n := s;
end;

procedure TestNullableString.TestReadNull;
begin
  CheckException(ReadNull, ENullReference);
end;

procedure TestNullableString.ReadUnint;
var
  n: NullableString;
  s: string;
begin
  s := n; // Should generate exception
  n := s;
end;

procedure TestNullableString.TestUninit;
begin
  CheckException(ReadUnint, ENullReference);
end;

initialization
  // Register any test cases with the test runner
  RegisterTest(TestNullableString.Suite);
end.

